﻿/*
创建人：zhangrj
日期：2023-12-07
描述：自动开卡页面维护js
*/
var page = {
  rootPath: getRootPath(), //网站根路径
  url: getRootPath() + "/Ashx/AutoStartContainerHandler.ashx",
  //初始化页面
  init: function () {
    page.bind();
    notCardPage.init();
    beCardPage.init();
    taskCardPage.init();
    errorPage.init();
    page.getFactory();
  },
  //页面事件绑定
  bind: function () {
    //查询按钮
    $('#btnSearch').on("click", function () {
      page.clearPage(false, true, true, true);
      var tab = $('#tt').tabs('getSelected');
      var index = $('#tt').tabs('getTabIndex', tab);
      switch (index) {
        case 0: //未开卡查询
          notCardPage.pageNumber = 1;
          notCardPage.searchData();
          break;
        case 1: //已开卡查询
          beCardPage.pageNumber = 1;
          beCardPage.searchData();
          break;
        case 2: //已开卡查询
          taskCardPage.pageNumber = 1;
          taskCardPage.searchData();
          break;
        case 3: //异常记录查询
          errorPage.pageNumber = 1;
          errorPage.searchData();
          break;
        default:
          displayMessage("未知功能", false);
          break;
      }
    });
    //清除按钮
    $('#btnReset').on("click", function () {
      page.clearPage(true, true, true, true);
    });
    //切换
    $('#tt').tabs({
      onSelect: function (title, index) {
        switch (title) {
          case "未开卡":
            notCardPage.showSearch();
            break;
          case "已开卡(一键开卡)":
            beCardPage.showSearch();
            break;
          case "已开卡(定时任务)":
            taskCardPage.showSearch();
            break;
          case "异常记录":
            errorPage.showSearch();
            break;
          default:
            displayMessage("未知功能", false);
            break;
        }
      }
    });
  },
  // 获取分厂列表
  getFactory: function () {
    $.ajax({
      type: "post",
      url: getRootPath() + "/Ashx/ApsHandler/EmployeeMaintPage.ashx?actions=getFactory",
      data: { action: "GetFactory" },
      cashe: false,
      dataType: 'json',
      success: function (res) {
        if (res.Result) {
          // 绑定弹出框分厂下拉框
          $("#ddlFactory").combobox({
            valueField: 'factoryid',
            textField: 'factoryname',
            panelHeight: 200,
            data: res.DBTable,
            onSelect: function (record) {
              if (record.factoryid) {
                page.getWorkcenter(record.factoryid);
                $('#ddlTeam').combobox('clear');
                $('#ddlTeam').combobox('loadData', []);
              }
            }
          });

          $.ajax({
            type: "post",
            url: getRootPath() + "/Ashx/ProductTeamInfoMaintPageHandler.ashx?actions=getUserInfo",
            data: { action: "getUserInfo" },
            cashe: false,
            dataType: 'json',
            success: function (res) {
              if (res.Result) {
                if (res.ReturnData.FactoryID) {
                  $("#ddlFactory").combobox('select', res.ReturnData.FactoryID);
                  // $('#ddlFactory').combobox('disable');
                  page.getWorkcenter(res.ReturnData.FactoryID);
                }
              } else {
                displayMessage(res.Message, false);
              }
            }
          });
        }
      }
    });
  },
  // 查询中心
  getWorkcenter: function (factoryid) {
    $.ajax({
      type: "post",
      url: getRootPath() + "/Ashx/ProductTeamInfoMaintPageHandler.ashx?actions=getWorkcenter",
      data: { action: "getWorkcenter", factoryid: factoryid },
      cashe: false,
      dataType: 'json',
      success: function (res) {
        if (res.Result) {
          $("#ddlWorkcenter").combobox({
            valueField: 'workcenterid',
            textField: 'workcentername',
            panelHeight: 200,
            data: res.DBTable,
            onSelect: function (record) {
              if (record.workcenterid) {
                page.getTeam(record.workcenterid, 'ddlTeam');
              }
            }
          });

          $("#ddlWorkcenter2").combobox({
            valueField: 'workcenterid',
            textField: 'workcentername',
            panelHeight: 200,
            data: res.DBTable,
            onSelect: function (record) {
              if (record.workcenterid) {
                page.getTeam(record.workcenterid, 'ddlTeam2');
              }
            }
          });
        }
      }
    });
  },
  // 查询单元（班组）
  getTeam: function (workcenterid, domid) {
    $.ajax({
      type: "post",
      url: getRootPath() + "/Ashx/ProductTeamInfoMaintPageHandler.ashx?actions=getTeam",
      data: { action: "getTeam", workcenterid: workcenterid },
      cashe: false,
      dataType: 'json',
      success: function (res) {
        if (res.Result) {
          $("#" + domid).combobox({
            valueField: 'teamid',
            textField: 'teamname',
            panelHeight: 200,
            data: res.DBTable
          });
        }
      }
    });
  },
  //禁用页面所有按钮
  disableBtn: function () {
    $("body").find(".easyui-linkbutton").each(function () {
      $(this).linkbutton('disable');
    });
    $('#tt').tabs('disableTab', 0);
    $('#tt').tabs('disableTab', 1);
    $('#tt').tabs('disableTab', 2);
    $("#mask").show();
  },
  //启用页面所有按钮
  enableBtn: function () {
    $("body").find(".easyui-linkbutton").each(function () {
      $(this).linkbutton('enable');
    });
    $('#tt').tabs('enableTab', 0);
    $('#tt').tabs('enableTab', 1);
    $('#tt').tabs('enableTab', 2);
    $("#mask").hide();
  },
  //清除页面（查询区域，列表区域，填写区域，是否清空消息，是否重置分页参数）
  clearPage: function (query, list, msg, pager) {
    if (query) {
      $('#ddlWorkcenter').combobox('clear');
      $('#ddlTeam').combobox('clear');
      $('#ddlTeam').combobox('loadData', []);
      $("#queryForm").find(".easyui-textbox").each(function () {
        $(this).textbox("clear");
      });
      $("#queryForm").find(".easyui-datebox").each(function () {
        $(this).datebox("clear");
      });
    }
    if (list) {
      clearEasyuiDataGrid("gdContainerInfoNot"); //清空列表
      clearEasyuiDataGrid("gdContainerInfoOff"); //清空列表
      clearEasyuiDataGrid("gdContainerInfoError"); //清空列表
    }
    if (msg) {
      clearMessage();
    }
    if (pager) {
      //未开卡页面分页参数重置
      $("#progressBar").hide();
      $("#gdContainerInfoNot").datagrid("hideColumn", "IsError");
      $("#gdContainerInfoNot").datagrid("hideColumn", "Message");
      notCardPage.pageNumber = 1; notCardPage.pageTotal = 0
      $('#ppNot').pagination('refresh', {
        total: notCardPage.pageTotal,
        pageSize: notCardPage.pageSize,
        pageNumber: notCardPage.pageNumber
      });
      //已开卡页面分页参数重置
      beCardPage.pageNumber = 1; beCardPage.pageTotal = 0
      $('#ppEnd').pagination('refresh', {
        total: beCardPage.pageTotal,
        pageSize: beCardPage.pageSize,
        pageNumber: beCardPage.pageNumber
      });
      //出错页面分页参数重置
      errorPage.pageNumber = 1; errorPage.pageTotal = 0
      $('#ppError').pagination('refresh', {
        total: errorPage.pageTotal,
        pageSize: errorPage.pageSize,
        pageNumber: errorPage.pageNumber
      });
    }
  },
  //post数据（路径，参数，是否异步，成功返回方法）
  post: function (url, param, async, callback) {
    $.ajax({
      type: "Post",
      url: url,
      data: param,
      cashe: false,
      async: async,
      dataType: "json",
      beforeSend: function () {
        $.messager.progress({ text: '', msg: '处理中...' });
      },
      success: function (data) {
        $.messager.progress('close');
        callback(data);
      },
      error: function (XMLHttpRequest, textStatus, errorThrown) {
        $.messager.progress('close');
        displayMessage(XMLHttpRequest.responseText, false);
        $("body").find(".easyui-linkbutton").each(function () {
          $(this).linkbutton('enable');
        });
      }
    });
  }
};
//未开卡
var notCardPage = {
  selectedRows: {}, //选择的数据
  progress: 0, //总进度
  pageTotal: 0,
  pageSize: 20,
  pageNumber: 1,
  //初始化页面
  init: function () {
    notCardPage.bind();
    notCardPage.showSearch();
    customizedEasyuiPagination('ppNot'); //定制化分页
  },
  //页面事件绑定
  bind: function () {
    //列表加载
    $("#gdContainerInfoNot").datagrid({
      onLoadSuccess: function (data) {
        $('#ppNot').pagination('refresh', {	// 改变选项，并刷新分页栏信息
          total: notCardPage.pageTotal,
          pageSize: notCardPage.pageSize,
          pageNumber: notCardPage.pageNumber
        });
        customizedEasyuiPagination('ppNot'); //定制化分页
      },
      columns: [[
        { field: 'ck', title: '选择', checkbox: true },
        { field: 'IsError', title: '状态', width: 80, hidden: true },
        { field: 'Message', title: '消息', width: 200, hidden: true },
        { field: 'MFGORDERNAME', title: '订单号', width: 120 },
        { field: 'PRODUCTNAME', title: '件号', width: 180 },
        { field: 'TEAMNAME', title: '件号主制单元', width: 100 },
        { field: 'MRPCONTROL', title: 'MRP控制者', width: 150 },
        { field: 'QTY', title: '开卡数量', width: 80 },
        { field: 'PRODUCTFAMILYNAME', title: '机型', width: 150 },
        { field: 'UOMNAME', title: '计量类型', width: 80 },
        {
          field: 'PLANNEDSTARTDATE', title: '计划开始日期', width: 120, formatter: function (value, row, index) {
            if (!isNullOrWhiteSpaceStr(value)) {
              return dayjs(value).format('YYYY-MM-DD HH:mm:ss');
            }
          }
        },
        {
          field: 'PLANNEDCOMPLETIONDATE', title: '计划结束日期', width: 120, formatter: function (value, row, index) {
            if (!isNullOrWhiteSpaceStr(value)) {
              return dayjs(value).format('YYYY-MM-DD HH:mm:ss');
            }
          }
        },
        {
          field: 'ISRULE', title: '开卡规则', width: 80, formatter: function (value, row, index) {
            if (value === 0) {
              return "";
            } else {
              return '<a class="btnNews" onclick="notCardPage.loadRuleData(\'' + row.PRODUCTNAME + '\')">规则查看</a>'
            }
          }
        }
      ]]
    });
    //分页事件
    $('#ppNot').pagination({
      onSelectPage: function (pageNumber, pageSize) {
        customizedEasyuiPagination('ppNot'); //定制化分页
        notCardPage.pageSize = pageSize; notCardPage.pageNumber = pageNumber;
        notCardPage.searchData();
      }
    });
    //绑定分页go按钮
    $('#pageGoNot').on("click", function () {
      var pageNumber = $(this).parents('tr').find('.pagination-num').val();
      notCardPage.pageNumber = pageNumber;
      notCardPage.searchData();
    });
    //一键开卡
    $("#btnOneKeyStart").on("click", function () {
      notCardPage.oneKeyStart();
    });
    $('#progressBar').progressbar({
      width: '100%',
      height: '12',
      value: '0',
      text: '{value}%'
    });
  },
  //查询
  searchData: function () {
    var params = {
      action: "GetNotStartContainerInfo",
      pageSize: notCardPage.pageSize,
      pageIndex: notCardPage.pageNumber
    };
    var datas = $("#queryForm").serializeArray();
    $.each(datas, function () {
      params[this.name] = this.value;
    });
    page.post(page.url, params, true, function (res) {
      if (!res.Result) {
        displayMessage(res.Message, res.Result);
        return;
      }
      notCardPage.pageTotal = res.RowCount;
      $("#gdContainerInfoNot").datagrid('loadData', { total: res.RowCount, rows: res.DBTable });
    });
  },
  //加载规则数据
  loadRuleData: function (productName) {
    page.post(page.url, { action: "GetContainerStartRuleDetailInfo", productName: productName }, true, function (res) {
      if (!res.Result) {
        displayMessage(res.Message, res.Result);
        return;
      }
      $('#dgRule').dialog(); //打开弹窗
      var data = res.DBTable[0];
      $("#txtAsProductName").val(data.PRODUCTNAME);
      $("#asProductDesc").val(data.DESCRIPTION);
      $("#asProductRev").val(data.PRODUCTREVISION);
      $("#asWorkflowName").val(data.WORKFLOWNAME);
      $("#asWorkflowRev").val(data.WORKFLOWREVISION);
      $("#asWorkCenter").val(data.WORKCENTERNAME);
      $("#asTechnologyName").val(data.TECHNOLOGYEMPNAME);
      $("#asContainerType").val(data.CONTAINERTYPENAME);
      $("#asIsSelfMfg").val(data.ISSELFMFGNAME);
      $("#asIsCutContainer").val(data.ISCUTCONTAINERNAME);
      $("#asCutQty").val(data.CUTQTY);
      $("#asCutStartStep").val(data.CUTSTARTSTEP);
    });
  },
  //一键开卡
  oneKeyStart: function () {
    page.disableBtn();
    notCardPage.selectedRows = $("#gdContainerInfoNot").datagrid("getChecked");
    if (notCardPage.selectedRows.length === 0) {
      page.enableBtn();
      displayMessage("请选择开卡数据", false);
      return;
    }
    var isInValid = false;
    for (var i = 0; i < notCardPage.selectedRows.length; i++) {
      if (!isNullOrWhiteSpaceStr(notCardPage.selectedRows[i].IsError)) {
        isInValid = true;
        break;
      }
    }
    if (isInValid) {
      page.enableBtn();
      displayMessage("存在提交过的数据，请重新查询后再操作", false);
      return;
    }
    $("#gdContainerInfoNot").datagrid("showColumn", "IsError"); //显示处理状态
    $("#gdContainerInfoNot").datagrid("showColumn", "Message"); //显示处理结果
    $("#progressBar").show(); //显示总进度条
    notCardPage.setProgressBar(0); //默认为零
    notCardPage.progress = Math.ceil(notCardPage.selectedRows.length / 6); //进度占比
    notCardPage.asyncPost(0); //提交开卡数据（从第一条开始）
  },
  //循环异步提交开卡信息（递归）
  asyncPost: function (index) {
    var formData = {
      action: "OneKeyStartContainerInfo",
      param: JSON.stringify(notCardPage.selectedRows[index])
    };
    $.ajax({
      type: "Post",
      url: page.url,
      data: formData,
      cashe: true,
      async: true,
      dataType: "json",
      beforeSend: function () {
        $.messager.progress({ text: '', msg: '处理中...' });
      },
      success: function (res) {
        $.messager.progress('close');
        notCardPage.setCellsStatus(index, res.Result, res.Message);
      },
      error: function (XMLHttpRequest, textStatus, errorThrown) {
        $.messager.progress('close');
        notCardPage.setCellsStatus(index, false, "页面提交失败，请刷新后重新提交");
      }
    });
  },
  //设置每行数据的结果状态
  setCellsStatus: function (index, result, message) {
    //更新行消息
    var ix = $("#gdContainerInfoNot").datagrid("getRowIndex", notCardPage.selectedRows[index]);
    if (result) {
      notCardPage.selectedRows[index].IsError = "<span style='color:#1E90FF'>成功</span>";
    } else {
      notCardPage.selectedRows[index].IsError = "<span style='color:#EE2C2C'>失败</span>";
    }
    notCardPage.selectedRows[index].Message = '<span title=' + message + '>' + message + '</span>';
    $('#gdContainerInfoNot').datagrid('updateRow', {
      index: ix,
      row: notCardPage.selectedRows[index]
    });
    $('#gdContainerInfoNot').datagrid('refreshRow', ix); //刷新行
    //如果是最后一条数据，则终止
    if (index + 1 === notCardPage.selectedRows.length) {
      notCardPage.setProgressBar(100);
      displayMessage("处理完成", true);
      page.enableBtn();
      $('#gdContainerInfoNot').datagrid('acceptChanges');
      return;
    }
    notCardPage.setProgressBar(notCardPage.progress * (index + 1)); //设置总进度条
    notCardPage.asyncPost(index + 1); //继续循环下一条数据
  },
  //设置总进度条
  setProgressBar: function (value) {
    $('#progressBar').progressbar('setValue', value);
  },
  //显示自身需要的查询
  showSearch: function () {
    $("#divScanOrder").show();
    $("#divProductName").show();
    $("#divContainerName").hide();
    $("#divStartDate").hide();
  }
};
//已开卡(一键开卡)
var beCardPage = {
  pageTotal: 0,
  pageSize: 20,
  pageNumber: 1,
  //初始化页面
  init: function () {
    beCardPage.bind();
    customizedEasyuiPagination('ppEnd'); //定制化分页
  },
  //页面事件绑定
  bind: function () {
    //列表加载
    $("#gdContainerInfoOff").datagrid({
      onLoadSuccess: function (data) {
        $('#ppEnd').pagination('refresh', {	// 改变选项，并刷新分页栏信息
          total: beCardPage.pageTotal,
          pageSize: beCardPage.pageSize,
          pageNumber: beCardPage.pageNumber
        });
        customizedEasyuiPagination('ppEnd'); //定制化分页
      },
      columns: [[
        { field: 'ck', title: '选择', checkbox: true },
        { field: 'MFGORDERNAME', title: '订单号', width: 120 },
        { field: 'CONTAINERNAME', title: '批次', width: 180 },
        { field: 'PRODUCTNAME', title: '件号', width: 150 },
        { field: 'TEAMNAME', title: '件号主制单元', width: 100 },
        { field: 'WORKFLOWNAMEANDREV', title: '工艺', width: 180 },
        { field: 'WORKFLOWSTEPNAME', title: '工序', width: 150 },
        { field: 'CONTAINERTYPENAME', title: '批次类型', width: 100 },
        { field: 'QTY', title: '在制数', width: 60 },
        {
          field: 'CREATEDATE', title: '开卡日期', width: 100,
          formatter: function (value, row, index) {
            if (!isNullOrWhiteSpaceStr(value)) {
              return dayjs(value).format('YYYY-MM-DD');
            }
          }
        }
      ]]
    });
    //分页事件
    $('#ppEnd').pagination({
      onSelectPage: function (pageNumber, pageSize) {
        customizedEasyuiPagination('ppEnd'); //定制化分页
        beCardPage.pageSize = pageSize; beCardPage.pageNumber = pageNumber;
        beCardPage.searchData();
      }
    });
    //绑定分页go按钮
    $('#pageGoEnd').on("click", function () {
      var pageNumber = $(this).parents('tr').find('.pagination-num').val();
      beCardPage.pageNumber = pageNumber;
      beCardPage.searchData();
    });
  },
  //查询
  searchData: function () {
    var params = {
      pageSize: beCardPage.pageSize,
      pageIndex: beCardPage.pageNumber,
      type: "手动"
    };
    var datas = $("#queryForm").serializeArray();
    $.each(datas, function () {
      params[this.name] = this.value;
    });
    var formData = {
      action: "GetContainerMakeingInfo",
      params: JSON.stringify(params)
    };
    page.post(page.url, formData, true, function (res) {
      if (!res.Result) {
        displayMessage(res.Message, res.Result);
        return;
      }
      beCardPage.pageTotal = res.RowCount;
      $("#gdContainerInfoOff").datagrid('loadData', { total: res.RowCount, rows: res.DBTable });
    });
  },
  //显示自身需要的查询
  showSearch: function () {
    $("#divScanOrder").show();
    $("#divProductName").show();
    $("#divContainerName").show();
    $("#divStartDate").show();
  }
};
//已开卡(定时任务)
var taskCardPage = {
  pageTotal: 0,
  pageSize: 20,
  pageNumber: 1,
  //初始化页面
  init: function () {
    taskCardPage.bind();
    customizedEasyuiPagination('ppTask'); //定制化分页
  },
  //页面事件绑定
  bind: function () {
    //列表加载
    $("#gdTaskContainerInfo").datagrid({
      onLoadSuccess: function (data) {
        $('#ppTask').pagination('refresh', {	// 改变选项，并刷新分页栏信息
          total: taskCardPage.pageTotal,
          pageSize: taskCardPage.pageSize,
          pageNumber: taskCardPage.pageNumber
        });
        customizedEasyuiPagination('ppTask'); //定制化分页
      },
      columns: [[
        { field: 'ck', title: '选择', checkbox: true },
        { field: 'MFGORDERNAME', title: '订单号', width: 120 },
        { field: 'CONTAINERNAME', title: '批次', width: 180 },
        { field: 'PRODUCTNAME', title: '件号', width: 150 },
        { field: 'TEAMNAME', title: '件号主制单元', width: 100 },
        { field: 'WORKFLOWNAMEANDREV', title: '工艺', width: 180 },
        { field: 'WORKFLOWSTEPNAME', title: '工序', width: 150 },
        { field: 'CONTAINERTYPENAME', title: '批次类型', width: 100 },
        { field: 'QTY', title: '在制数', width: 60 },
        {
          field: 'CREATEDATE', title: '开卡日期', width: 100,
          formatter: function (value, row, index) {
            if (!isNullOrWhiteSpaceStr(value)) {
              return dayjs(value).format('YYYY-MM-DD');
            }
          }
        }
      ]]
    });
    //分页事件
    $('#ppTask').pagination({
      onSelectPage: function (pageNumber, pageSize) {
        customizedEasyuiPagination('ppTask'); //定制化分页
        taskCardPage.pageSize = pageSize; taskCardPage.pageNumber = pageNumber;
        taskCardPage.searchData();
      }
    });
    //绑定分页go按钮
    $('#pageGoTask').on("click", function () {
      var pageNumber = $(this).parents('tr').find('.pagination-num').val();
      taskCardPage.pageNumber = pageNumber;
      taskCardPage.searchData();
    });
    //导出异常数据
    $('#btnExportTaskContainer').on("click", function () {
      var params = { action: "ExportTaskContainerToExcel" };
      var datas = $("#queryForm").serializeArray();
      $.each(datas, function () {
        params[this.name] = this.value;
      });
      FileDownLoad(page.url, params);//下载文件
    });
  },
  //查询
  searchData: function () {
    var params = {
      pageSize: taskCardPage.pageSize,
      pageIndex: taskCardPage.pageNumber,
      type: "自动"
    };
    var datas = $("#queryForm").serializeArray();
    $.each(datas, function () {
      params[this.name] = this.value;
    });
    var formData = {
      action: "GetContainerMakeingInfo",
      params: JSON.stringify(params)
    };
    page.post(page.url, formData, true, function (res) {
      if (!res.Result) {
        displayMessage(res.Message, res.Result);
        return;
      }
      taskCardPage.pageTotal = res.RowCount;
      $("#gdTaskContainerInfo").datagrid('loadData', { total: res.RowCount, rows: res.DBTable });
    });
  },
  //显示自身需要的查询
  showSearch: function () {
    $("#divScanOrder").show();
    $("#divProductName").show();
    $("#divContainerName").show();
    $("#divStartDate").show();
  }
};
//错误日志
var errorPage = {
  pageTotal: 0,
  pageSize: 20,
  pageNumber: 1,
  //初始化页面
  init: function () {
    errorPage.bind();
    customizedEasyuiPagination('ppError'); //定制化分页
  },
  //页面事件绑定
  bind: function () {
    //列表加载
    $("#gdContainerInfoError").datagrid({
      onLoadSuccess: function (data) {
        $('#ppError').pagination('refresh', {	// 改变选项，并刷新分页栏信息
          total: errorPage.pageTotal,
          pageSize: errorPage.pageSize,
          pageNumber: errorPage.pageNumber
        });
        customizedEasyuiPagination('ppError'); //定制化分页
      },
      columns: [[
        { field: 'MFGORDERNAME', title: '订单', width: 180 },
        { field: 'PRODUCTNAME', title: '件号', width: 150 },
        { field: 'TEAMNAME', title: '件号主制单元', width: 100 },
        {
          field: 'NOTES', title: '出错描述', width: 250,
          formatter: function (value, row, index) {
            return '<span title=' + value + '>' + value + '</span>';
          }
        },
        { field: 'FULLNAME', title: '创建人', width: 80 },
        {
          field: 'CREATEDATE', title: '创建日期', width: 120,
          formatter: function (value, row, index) {
            if (!isNullOrWhiteSpaceStr(value)) {
              return dayjs(value).format('YYYY-MM-DD');
            }
          }
        }
      ]]
    });
    //分页事件
    $('#ppError').pagination({
      onSelectPage: function (pageNumber, pageSize) {
        customizedEasyuiPagination('ppError'); //定制化分页
        errorPage.pageSize = pageSize; errorPage.pageNumber = pageNumber;
        errorPage.searchData();
      }
    });
    //绑定分页go按钮
    $('#pageGoError').on("click", function () {
      var pageNumber = $(this).parents('tr').find('.pagination-num').val();
      errorPage.pageNumber = pageNumber;
      errorPage.searchData();
    });
    //导出异常数据
    $('#btnExportError').on("click", function () {
      var params = { action: "ExportErrorInfoToExcel" };
      FileDownLoad(page.url, params); //下载文件
    });
  },
  //查询
  searchData: function () {
    var params = {
      pageSize: errorPage.pageSize,
      pageIndex: errorPage.pageNumber,
      mfgOrderName: $("#txtScanOrder").textbox("getValue"),
      productName: $("#txtProductName").textbox("getValue"),
      ddlFactory: $("#ddlFactory").combobox("getValue"),
      ddlWorkcenter: $("#ddlWorkcenter").combobox("getValue"),
      ddlTeam: $("#ddlTeam").combobox("getValue")
    };
    var formData = {
      action: "GetContainerErrorInfo",
      params: JSON.stringify(params)
    };
    page.post(page.url, formData, true, function (res) {
      if (!res.Result) {
        displayMessage(res.Message, res.Result);
        return;
      }
      errorPage.pageTotal = res.RowCount;
      $("#gdContainerInfoError").datagrid('loadData', { total: res.RowCount, rows: res.DBTable });
    });
  },
  //显示自身需要的查询
  showSearch: function () {
    $("#divScanOrder").show();
    $("#divProductName").show();
    $("#divContainerName").hide();
    $("#divStartDate").hide();
  }
};
$(function () {
  page.init();
});